<template>
  <div class="container">
    <div
      class="select-item"
      :class="activeIndex == index ? 'active' : ''"
      v-for="(text, index) of list"
      :key="index"
      @click="clickHandle(index)"
      v-ripple="{ color: '#e9b10e' }"
    >
      {{ text }}
    </div>
  </div>
</template>

<script>
export default {
  name: 'select-tab',
  props: {
    list: {
      type: Array,
      default() {
        return []
      }
    },
  },
  data() {
    return {
      activeIndex: 0
    }
  },
  methods: {
    clickHandle(index) {
      this.activeIndex = index
      this.$emit('selectIndex', index)
    }
  }
}
</script>

<style lang="less" scoped>
.container {
  display: flex;
  justify-content: center;
  padding: 0 45px;
  box-sizing: border-box;

  .select-item {
    position: relative;
    flex: 1;
    font-size: 20px;
    text-align: center;
    height: 48px;
    line-height: 48px;
    box-sizing: border-box;
    border-bottom: 2px solid transparent;
    color: #848492;
    font-family: 'Roboto', 'Helvetica', 'Arial', sans-serif;
    font-weight: 500;
    white-space: normal;
    letter-spacing: 0.02857em;
    overflow: hidden;
    transition: border-color 0.3s;

    &.active {
      color: #e9b10e;
      border-bottom: 2px solid #e9b10e;
    }
  }

  @media screen and (max-width: 414px) {
    & {
      padding: 0 15px;
    }
  }
}
</style>
